﻿using System.Drawing;
using RaytracerLib.Layers;
using RaytracerLib.MathLib;
using TomanuExtensions;

namespace RaytracerLib.Postprocessing.LightCorrector
{
    public class ClipEachPixelToneMapper : ToneMapper
    {
        internal override void Postprocess(Rectangle a_src_rect, ColorArrayFloat a_ar)
        {
            foreach (var p in a_src_rect.EnumPixels())
            {
                ColorFloat c = a_ar.GetColor(p.X, p.Y);
                c = new ColorFloat(
                    c.R > 1 ? 1 : c.R,
                    c.G > 1 ? 1 : c.G,
                    c.B > 1 ? 1 : c.B);
                a_ar.SetColor(p.X, p.Y, c);
            }
        }

        public override bool RequiredPostprocessingFinalization
        {
            get
            {
                return false;
            }
        }
    }
}